package chapter7.No7_2_线程组.f组内的线程批量停止;

/**
 * !
 *
 * @author liujian
 * @version 2016/12/8 0008
 */
public class Main {
    static class MyThread extends Thread {
        public MyThread(ThreadGroup group, String s) {
            super(group, s);
        }

        @Override
        public void run() {
            System.out.println("进入run 线程" + Thread.currentThread().getName());
            while(!this.isInterrupted()) {
            }
            System.out.println("退出run 线程" + Thread.currentThread().getName());
        }
    }

    public static void main(String[] args) throws InterruptedException {
        ThreadGroup group = new ThreadGroup("线程组A");
        for(int i = 0; i < 5; i++) {
            MyThread a = new MyThread(group, "A"+(i+1));
            a.start();
        }
        Thread.sleep(1000);
        group.interrupt();
        System.out.println("线程停止");
    }
}
